package customerService

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/pkg/code"
	"gitee.com/liuxuezhan/ar-platform/rpc-client/setting/client/customerservicegroup"
	"github.com/zeromicro/go-zero/core/logc"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelCustomerServiceLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 删除客服管理
func NewDelCustomerServiceLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelCustomerServiceLogic {
	return &DelCustomerServiceLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DelCustomerServiceLogic) DelCustomerService(req *types.CustomerServiceInfoReq) (resp *types.Empty, err error) {
	if req.Id == 0 {
		return nil, code.ParamsInvalid
	}

	u, err := l.svcCtx.SettingService.CustomerService.DelCustomerService(l.ctx, &customerservicegroup.CustomerServiceInfoReq{MerchantId: 1, Id: req.Id})

	if err != nil {
		logc.Error(l.ctx, "DelCustomerService err:", err)
		return nil, err
	}

	if u.Code != int64(code.SettingRpcSuccessful.Code()) {
		return nil, code.BusinessFailure
	}
	resp = &types.Empty{}
	return
}
